/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;
import Data.KhachHang;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @author bienphongvnn
 */
public class checkLogin {
    public static ResultSet rs = null;
    public static PreparedStatement pst = null;
    public boolean checkUser(String email, String password) {
        rs = Login(email, password);
        try {
            if (rs.next()) {
                return true;
            } else {
                return false;
            }
        } catch (Exception ex) {
            ex.getMessage();
            return false;
        }
    }

   
    public static ResultSet Login(String user, String pass) {
        try {
            Connection conn = ConnectionProvider.Connect();
            String sql = "Select * from khachhang where Email = ? and MatKhau = ?";
            pst = conn.prepareStatement(sql);
            pst.setString(1, user);
            pst.setString(2, pass);
            return rs = pst.executeQuery();
        } catch (Exception ex) {
            return null;
        }
    }
    
}
